package com.xxx.borrow.ui.wallet;

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.xxx.borrow.ConfigClass;
import com.xxx.borrow.R;
import com.xxx.borrow.base.fragment.BaseFragment;
import com.xxx.borrow.ui.wallet.activity.RechargeActivity;
import com.xxx.borrow.ui.wallet.activity.WithdrawalActivity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;

/**
 * @Page 钱包布局
 * @Author xxx
 */
public class WalletFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener, BaseQuickAdapter.OnItemChildClickListener {

    @BindView(R.id.main_wallet_recycler)
    RecyclerView mRecycler;
    @BindView(R.id.main_not_data)
    LinearLayout mNotData;
    @BindView(R.id.main_wallet_refresh)
    SwipeRefreshLayout mRefresh;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_wallet;
    }

    @Override
    protected void initData() {
        EventBus.getDefault().register(this);
    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
        switch (view.getId()) {
            case R.id.item_wallet_recharge:
//                RechargeActivity.actionStart(getActivity(), bean.getAddress(), bean.getCoinId(), bean.getCoinName());
                RechargeActivity.actionStarts(getActivity());
                break;
            case R.id.item_wallet_withdrawal:
//                WithdrawalActivity.actionStart(getActivity(), bean.getAmount(), bean.getFee(), bean.getCoinId(), bean.getCoinName(), bean.getAddress());
                WithdrawalActivity.actionStarts(getActivity());
                break;
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventBus(String eventFlag) {
        switch (eventFlag) {
            case ConfigClass.EVENT_UPDATE_WALLET:
                //刷新
                break;
        }
    }

    @Override
    public void onRefresh() {
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

}
